<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="channels" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{channelsHome.managed ? 'Edit' : 'Add'} Channels</f:facet>


            <s:decorate id="epgPosField" template="layout/edit.xhtml">
                <ui:define name="label">Epg pos</ui:define>
                <h:inputText id="epgPos"
                       disabled="#{channelsHome.managed}"
                       required="true"
                           size="4"
                      maxlength="4"
                          value="#{channelsHome.instance.epgPos}">
                    <a:support event="onblur" reRender="epgPosField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="nameField" template="layout/edit.xhtml">
                <ui:define name="label">Name</ui:define>
                <h:inputText id="name"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{channelsHome.instance.name}">
                    <a:support event="onblur" reRender="nameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="imageField" template="layout/edit.xhtml">
                <ui:define name="label">Image</ui:define>
                <h:inputText id="image"
                           size="100"
                      maxlength="100"
                          value="#{channelsHome.instance.image}">
                    <a:support event="onblur" reRender="imageField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="favouriteField" template="layout/edit.xhtml">
                <ui:define name="label">Favourite</ui:define>
                <h:inputText id="favourite"
                          value="#{channelsHome.instance.favourite}">
                    <a:support event="onblur" reRender="favouriteField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="channelSiglaField" template="layout/edit.xhtml">
                <ui:define name="label">Channel sigla</ui:define>
                <h:inputText id="channelSigla"
                           size="4"
                      maxlength="4"
                          value="#{channelsHome.instance.channelSigla}">
                    <a:support event="onblur" reRender="channelSiglaField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{channelsHome.persist}"
                       disabled="#{!channelsHome.wired}"
                       rendered="#{!channelsHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{channelsHome.update}"
                       rendered="#{channelsHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{channelsHome.remove}"
                      immediate="true"
                       rendered="#{channelsHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Channels.xhtml"
                rendered="#{channelsHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty channelsFrom ? 'ChannelsList' : channelsFrom}.xhtml"
                rendered="#{!channelsHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Tv programs">
        <h:form styleClass="association" id="tvProgramsChildren">

            <h:outputText value="There are no tvPrograms associated with this channels."
                       rendered="#{empty channelsHome.tvPrograms}"/>

            <rich:dataTable value="#{channelsHome.tvPrograms}"
                           var="_tvProgram"
                      rendered="#{not empty channelsHome.tvPrograms}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="tvProgramsTable">
                <rich:column sortBy="#{_tvProgram.programId}">
                    <f:facet name="header">Program id</f:facet>
                    <h:outputText value="#{_tvProgram.programId}"/>
                </rich:column>
                <rich:column sortBy="#{_tvProgram.dateTime}">
                    <f:facet name="header">Date time</f:facet>
                    <h:outputText value="#{_tvProgram.dateTime}">
                        <s:convertDateTime type="both" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_tvProgram.name}">
                    <f:facet name="header">Name</f:facet>
                    <h:outputText value="#{_tvProgram.name}"/>
                </rich:column>
                <rich:column sortBy="#{_tvProgram.shortDescription}">
                    <f:facet name="header">Short description</f:facet>
                    <h:outputText value="#{_tvProgram.shortDescription}"/>
                </rich:column>
                <rich:column sortBy="#{_tvProgram.longDescription}">
                    <f:facet name="header">Long description</f:facet>
                    <h:outputText value="#{_tvProgram.longDescription}"/>
                </rich:column>
                <rich:column sortBy="#{_tvProgram.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_tvProgram.id}"/>
                </rich:column>
                <rich:column sortBy="#{_tvProgram.endDateTime}">
                    <f:facet name="header">End date time</f:facet>
                    <h:outputText value="#{_tvProgram.endDateTime}">
                        <s:convertDateTime type="both" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{channelsHome.managed}" id="tvPrograms">
        <div class="actionButtons">
            <s:button id="addtvProgram"
                   value="Add tvProgram"
                    view="/TvProgramEdit.xhtml"
             propagation="none">
                 <f:param name="channelsEpgPos"
                         value="#{channelsHome.instance.epgPos}"/>
                 <f:param name="tvProgramFrom" value="Channels"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Channels categories">
        <h:form styleClass="association" id="channelsCategoriesChildren">

            <h:outputText value="There are no channelsCategories associated with this channels."
                       rendered="#{empty channelsHome.channelsCategories}"/>

            <rich:dataTable value="#{channelsHome.channelsCategories}"
                           var="_channelsCategory"
                      rendered="#{not empty channelsHome.channelsCategories}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="channelsCategoriesTable">
                <rich:column sortBy="#{_channelsCategory.id.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_channelsCategory.id.id}"/>
                </rich:column>
                <rich:column sortBy="#{_channelsCategory.id.epgpos}">
                    <f:facet name="header">Epgpos</f:facet>
                    <h:outputText value="#{_channelsCategory.id.epgpos}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{channelsHome.managed}" id="channelsCategories">
        <div class="actionButtons">
            <s:button id="addchannelsCategory"
                   value="Add channelsCategory"
                    view="/ChannelsCategoryEdit.xhtml"
             propagation="none">
                 <f:param name="channelsEpgPos"
                         value="#{channelsHome.instance.epgPos}"/>
                 <f:param name="channelsCategoryFrom" value="Channels"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
